Add Error Handling and Validation to Spring Boot Banking Application #63
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add Error Handling and Validation to Spring Boot Banking Application
Summary
This PR adds comprehensive error handling and validation infrastructure to the banking application, including custom exception classes, a global exception handler, validation DTOs, security error handlers, and service layer improvements with logging.
Key changes:
^[\w.-]+$)-DskipTests=truefrom DockerfileReview & Testing Checklist for Human
CRITICAL: Validation DTOs not integrated into controller - The DTOs (RegistrationRequest, TransferRequest, AmountRequest) were created with validation annotations but BankController still uses
@RequestParamdirectly. The controller needs to be updated to use@Valid @ModelAttributeor@Valid @RequestBodyfor validation to actually work.Test environment database setup - Removing
-DskipTests=truefrom Dockerfile will cause builds to fail if the CI environment doesn't have MySQL configured. Verify CI has proper database setup or consider adding an H2 in-memory database for tests.Username validation may break existing accounts - The new username pattern validation (
^[\w.-]+$) in AccountService.findAccountByUsername() could reject existing usernames that don't match this pattern. Verify existing data compatibility.Broad exception catching in service layer - Methods like deposit/withdraw/transfer catch generic
Exceptionand re-throw asRuntimeException, which could mask specific database errors.Recommended test plan:
Notes